import request from '@/utils/request'

export interface LoginParams {
  code: string
}

export interface LoginResult {
  code: number
  message: string
  token: string
}

export interface UserInfo {
  user:{
    nickName: string
    avatar: string
    sex: number
    phonenumber: string
    userId: string | number  // 添加userId字段
    weixinOpenId: string
  }
}

// 微信登录
export function wxLogin(params: LoginParams) {
  return request<LoginResult>({
    url: '/wxLogin',
    method: 'GET',
    data: params
  })
}

// 获取用户信息
export function getUserInfo() {
  return request<UserInfo>({
    url: '/getInfo',
    method: 'GET'
  })
}